package com.bdqn.miaoshaconsumer.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class DirectConfig {
    @Bean
    public Queue MyDirectQueue() {
        return new Queue("MiaoshaQueue", true);
    }

    @Bean
    DirectExchange directExchange() {
        return new DirectExchange("MiaoshaExchange", true, false);
    }

    @Bean
    Binding bindingDirect() {
        return BindingBuilder.bind(MyDirectQueue()).to(directExchange()).with("MiaoshaRouting");
    }

    @Bean
    MessageConverter messageConverter() {
        return new Jackson2JsonMessageConverter();
    }
}
